Component({
  methods: {
    downloadFile: function() {
      let fileUrl = 'https://aqn.youngch-cloud.com/pdf/youngchManual.pdf'
			let downloadTask = wx.downloadFile({
				url: fileUrl,
				header: {},
				success: (res) => {
					if (res.statusCode === 200) {
						console.log('下载成功')
						console.log(res)
						let file = wx.getFileSystemManager()
						// 上次上次下载的文件
						file.unlink({
							filePath: wx.env.USER_DATA_PATH + '/阳淳智能小程序使用说明.pdf',
							success: function(data) {
								console.log(data)
							}
						})
						file.saveFile({
							tempFilePath: res.tempFilePath,
							filePath: wx.env.USER_DATA_PATH + '/阳淳智能小程序使用说明.pdf',
							success: function(response) {
								console.log(response)
								wx.hideLoading()
								wx.showModal({
									title: '文件保存成功',
									content: '位于tencent/microMsg/wxanewfiles下,请根据最新下载时间打开文件夹',
									confirmColor: '#47C5C1',
									confirmText: '复制路径',
									showCancel: false,
									success: function(res2) {
										console.log(res2)
										if (res2.confirm) {
											wx.setClipboardData({
												data: 'wxanewfiles',
												success: function(res3) {
													console.log(res3)
												}
											})
										}
									}
								})
							}
						})
					}
				}
			})
			downloadTask.onProgressUpdate((res) => {
				wx.showLoading({
					title: `下载中${res.progress}%`
				})
			})
    }
  }
})